<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>添加管理员</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" href="admin/css/common.css" type="text/css" />
<link rel="stylesheet" href="admin/css/provider.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<link rel="stylesheet" href="./kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="./kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="./kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="./kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="./kindeditor/plugins/code/prettify.js"></script>

<script type="text/javascript">
		//判断是否为空
		function check(){
			if($('#title').val()==""){
				$('#titleTip').text("*名字不能为空");
				$('#title').focus();
				return false;
			}else if($('#password').val() =="" ){
				$('#pwdTip').text("*请输入密码");
				$('#pwdChkTip').text("");
				$('#password').focus();
				return false;
			}else if($('#password').val() != $('#passwordChk').val()){
				$('#pwdTip').text("");
				$('#pwdChkTip').text("*两次密码不相同");
				$('#passwordChk').focus();
				return false;
			}
			return true;
		}
		
		function checkName() {
			$('#titleFlag').val("no");
			if ($("#title").val() != "") {
				var params = {
					userName : $("#title").val(),
					checkflag : "add",
					adminId : $('#adminId').val()
				};
				jQuery.post("checkAdminNameExist.action", params, callbackFunc, "json");
			}
		}
		function callbackFunc(data) {
			if (data.existFlag > 0) {
				$('#titleTip').html('<font color="red">*名字已经存在</font>');
				$('#titleFlag').val("no");
			} else {
				$('#titleTip').html('<font color="green">名字可以使用</font>');
				$('#titleFlag').val("yes");
			}
		}
	</script>
</head>

<body>
	<div id="provider_zone">
		<form action="admin/savaAdministrator.action" name="administratorForm"
			enctype="multipart/form-data" method="post"
			onsubmit="return check();">
			<table width="99%" border="0" align="center" cellpadding="3"
				cellspacing="1" class="table_style">
				<tr>
					<td class="left_title_1">管理员名字&nbsp;</td>
					<td><input class="short-input" type="text"
						name="admin.username" id="title" onblur="checkName()"> <span
						class="tip" id="titleTip"></span><input type="hidden"
						id="titleFlag" value="yes" />
					</td>
				</tr>
				<tr>
					<td class="left_title_2">密码</td>
					<td><input type="password" id="password" name="admin.password" />
						<span class="tip" id="pwdTip"></span>
					</td>
				</tr>
				<tr>
					<td class="left_title_1">密码确认</td>
					<td><input type="password" id="passwordChk" name="passwordChk" />
						<span class="tip" id="pwdChkTip"></span>
					</td>
				</tr>
				<tr>
					<td colspan="2" class="left_title_2"><input type="submit"
						class="input-submit" value="保存">(提交快捷键: Ctrl + Enter)</td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>
